package com.three.controller;

import com.three.aop.LogAnotation;
import com.three.entity.Department;
import com.three.entity.Staff;
import com.three.service.DepartmentService;
import com.three.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/dept")
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;
    //获取部门名
    @RequestMapping("/getAll")
    public R getDeptName(){
        return departmentService.getAll();
    }
    //获取所有部门信息
    @PostMapping("/getAllDept")
    public R getDeptInfo(Integer currentPage, Integer pageSize, Department department){
        return departmentService.getAllDept(currentPage,pageSize,department);
    }
    //添加部门
    @PostMapping("/addDept")
    @LogAnotation("添加部门")//日志
    public R addDept(@RequestBody Department department){
        return departmentService.addDept(department);
    }
    //修改部门信息
    @PutMapping("/updateDept")
    @LogAnotation("修改部门信息")//日志
    public R updateDept(@RequestBody Department department){
        return departmentService.updateDept(department);
    }
    //删除部门
    @GetMapping("/deleteDept")
    @LogAnotation("删除部门")//日志
    public R deleteDept(Integer deptid){
        return departmentService.deleteDept(deptid);
    }

}
